import bpy
import os
import code
import mathutils
def main():
    filename = os.path.join(os.path.dirname(bpy.data.filepath),  "./2d3dc88e-ba45-49cc-a10b-f36efcc5f722_kpt.txt")
    text = open(filename).read()
    print(text)
    # namespace = globals().copy()
    # namespace.update(locals())
    # code.interact(local=namespace)

    bpy.ops.object.armature_add(view_align=False, enter_editmode=True, location=(0, 0, 0))

    lines = text.split("\n")
    index = 0
    for line in lines:
        index += 1
        if line:
            point = line.split(" ")
            print(point)
            bone_name = "bone" + str(index)
            bpy.ops.armature.bone_primitive_add(name=bone_name)
            bone = bpy.context.active_object.data.edit_bones[bone_name]
            loc = mathutils.Vector((float(point[0]) / 200 , -float(point[2]) / 200,-float(point[1]) / 200))
            bone.tail.x = loc.x 
            bone.tail.y = loc.y
            bone.tail.z = loc.z
            bone.head.x = loc.x 
            bone.head.y = loc.y + 0.1
            bone.head.z = loc.z